

#include<stdio.h>
void swap(int* a, int* b) {
	int c;
	c = *a;
	*a = *b;
	*b = c;
	return;
}
int partition(int r[], int m, int n) {
	int k = r[m], p = m + 1, g= n;
	while (p <= g) {
		while (p <= n && r[p] <=k) p++;
		while (r[g] > k) g--;
		if (p < g) { swap(&r[p], &r[g]); p++; g--; }
	}
	swap(&r[m], &r[g]);
	return g;
}
void quicksort(int r[], int m, int n,int e) {
	if (m <n) {
		int k=partition(r, m, n);
		for (int i = 0; i < e; i++) { printf("%d ", r[i]); } 
		printf("\n");
		quicksort(r, m, k - 1,e);
		quicksort(r, k + 1, n,e);
		
	}
}
int main() {
	int n, value[1010],i;
	scanf_s("%d", &n);
	for (i = 0; i < n; i++) {
		scanf_s("%d",&value[i]);
	}
	quicksort(value, 0, n-1,n);
	for (int i = 0; i < n; i++) { printf("%d ", value[i]); }
	printf("\n");
	return 0;
}